/*截取url地址中的appid和userId*/
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}
var WebSite = {

    //hostUrl : "http://10.176.1.143:8090/sool_web",
    //webSiteContextURL : "http://10.176.1.143:8090/sool_web/sool/f/",
    //ajaxExtFileName : "",
    //webFileName : "html",
    //websitePageURL : "http://10.176.1.143:8090/sool_web/",
    //enviromentType : "dev",

    hostUrl : "http://127.0.0.1:9080/sool_web",
    webSiteContextURL : "http://127.0.0.1:9080/sool_web/sool/f/",
    ajaxExtFileName : ".json",
    webFileName : "html",
    websitePageURL : "http://127.0.0.1:9080/sool_web/",
    enviromentType : "dev",


  /*  hostUrl : "http://www.nyyonyou.com/sool",
    webSiteContextURL : "http://www.nyyonyou.com/sool/sool/f/",
    ajaxExtFileName : "",
    webFileName : "html",
    websitePageURL : "http://www.nyyonyou.com/sool/",
    enviromentType : "dev",*/

    userappid: getUrlParam("userappid") ,
    userid: getUrlParam("userid"),


    allUrl : "?userappid=" + getUrlParam("userappid") + "&userid="+ getUrlParam("userid"),

    debugOn : false,
    debug : function(msgObj) {
        if (this.debugOn) {
            alert(msgObj);
        }
    },

    no_adopt                : 0,
    yes_adopt               : 1,
    askerWaitToAnswerStatus : 1,
    askerWaitToHandle       : 2,
    askerSolved             : 3,
    yes_zhuiwen             : 1,
    no_zhuiwen              : 0,

    /*renderNavBar : function(){

    }*/
};


WebSite.IndexPage = {
    url : WebSite.websitePageURL + "index.html"+WebSite.allUrl,
    myQuestion_list : WebSite.webSiteContextURL + "index/myquestion_list" + WebSite.ajaxExtFileName+WebSite.allUrl,
    showKnowPicture : WebSite.webSiteContextURL + "index/user_questioninfor" +WebSite.ajaxExtFileName+WebSite.allUrl,
    waitYouToAnswer : WebSite.webSiteContextURL + "index/othersquestion_list" + WebSite.ajaxExtFileName+WebSite.allUrl,
    record          : WebSite.webSiteContextURL + "index/searchranklist" +WebSite.ajaxExtFileName+WebSite.allUrl,
    essenceQuestion : WebSite.webSiteContextURL + "index/essencesquestion_list"+WebSite.ajaxExtFileName+WebSite.allUrl,


    /*getMyQuersionList : function() {
        if (appid && userid) {
            return WebSite.webSiteContextURL + "index/user_questioninfor" + WebSite.ajaxExtFileName;
        }
    }*/

};


WebSite.CommitPage = {
    url : WebSite.websitePageURL + "commitQuestion.html"+WebSite.allUrl,
    commitQuestion : WebSite.webSiteContextURL +"question_manager/submit_qustion" + WebSite.ajaxExtFileName+WebSite.allUrl,
    submitUserInfo : WebSite.webSiteContextURL + "user_manager/submit_userinfro" + WebSite.ajaxExtFileName+WebSite.allUrl,
    selectQuestion : WebSite.webSiteContextURL + "question_manager/query_questionfor_update" + WebSite.ajaxExtFileName+WebSite.allUrl,
    updateQuestion : WebSite.webSiteContextURL + "question_manager/update_question" + WebSite.ajaxExtFileName+WebSite.allUrl,
};


WebSite.SearchResultPage = {
    url                      : WebSite.websitePageURL + "search.html"+WebSite.allUrl,
    searchResult_list        : WebSite.webSiteContextURL + "index/searchquestion" + WebSite.ajaxExtFileName + WebSite.allUrl,
    //精华问题
    essencequestion_list     : WebSite.webSiteContextURL + "index/essencesquestion_list"+ WebSite.ajaxExtFileName + WebSite.allUrl,
    //相似问题
    similarQuestion          : WebSite.webSiteContextURL + "index/resemblequestion_list"+ WebSite.ajaxExtFileName + WebSite.allUrl

}




//提问者待解答状态
WebSite.AskerUnansweredPage = {
    url : WebSite.websitePageURL + "detailQuestionUnansweredMaster.html"+WebSite.allUrl,
    searchquestion_detail : WebSite.webSiteContextURL + "index/searchquestion_detail" + WebSite.ajaxExtFileName + WebSite.allUrl
}
//提问者待处理状态(追问)
WebSite.AskerHandlingPage = {
    url : WebSite.websitePageURL + "detailQuestionAnsweredMaster.html"+WebSite.allUrl,
    searchquestion_detail : WebSite.webSiteContextURL + "index/searchquestion_detail" + WebSite.ajaxExtFileName + WebSite.allUrl,
    //追问
    addQuestion : WebSite.webSiteContextURL + "question_manager/closely_qustion" + WebSite.ajaxExtFileName + WebSite.allUrl
}
//提问者已解决状态
WebSite.AskerSolvedPage = {
    url : WebSite.websitePageURL + "detailQuestionSolved.html"+WebSite.allUrl,
    searchquestion_detail : WebSite.webSiteContextURL + "index/searchquestion_detail" + WebSite.ajaxExtFileName + WebSite.allUrl,
    //处理采纳答案的接口
    adopt_answer : WebSite.webSiteContextURL + "answer_manager/adopt_answer" + WebSite.ajaxExtFileName + WebSite.allUrl
}
//回答者待解答状态(给出答案之前***)(回答问题)
WebSite.ReplyerUnansweredPage = {
    url : WebSite.websitePageURL + "detailQuestionUnansweredVistor.html"+WebSite.allUrl,
    searchquestion_detail : WebSite.webSiteContextURL + "index/searchquestion_detail" + WebSite.ajaxExtFileName + WebSite.allUrl,
    commitAnswer : WebSite.webSiteContextURL + "answer_manager/submit_answer" + WebSite.ajaxExtFileName + WebSite.allUrl
}

//回答者待处理状态(给出答案之前)
WebSite.ReplayerHandlingPage = {
    url : WebSite.websitePageURL + "dqAnsweredReplyer.html" + WebSite.allUrl,
    continueAnswer : WebSite.webSiteContextURL + "answer_manager/closely_answer" + WebSite.ajaxExtFileName + WebSite.allUrl
}

//回答者已解决状态
WebSite.ReplyerSolvedPage = {
    url : WebSite.websitePageURL + "detailQuestionSolved.html"+WebSite.allUrl
}
//浏览者待解答状态(给出答案之前)
WebSite.VisitorUnansweredPage = {
    url : WebSite.websitePageURL + "detailQuestionUnansweredVistor.html"+WebSite.allUrl
}

//浏览者已解决状态
WebSite.VisitorSolvedPage = {
    url : WebSite.websitePageURL + "detailQuestionSolved.html"+WebSite.allUrl
}
//未采纳待处理(yy)
WebSite.UnAdoptHandlingPage = {
    url : WebSite.websitePageURL + "dqUnAdoptedHandling.html"+WebSite.allUrl,
    questionAndAnswer : WebSite.webSiteContextURL + "index/myanswer_status1_detail" + WebSite.ajaxExtFileName + WebSite.allUrl
}










WebSite.MyQuestionListPage = {
    url :WebSite.websitePageURL + "myProblem.html"+WebSite.allUrl,
    //精华问题
    essencequestion_list :WebSite.webSiteContextURL + "index/essencesquestion_list"+ WebSite.ajaxExtFileName + WebSite.allUrl,

    myquestion_list_pageno: WebSite.webSiteContextURL + "index/myquestion_list_pageno" + WebSite.ajaxExtFileName + WebSite.allUrl,
    //待解答
    myquestion_stuts1list_pageno:WebSite.webSiteContextURL + "index/myquestion_stuts1list_pageno" + WebSite.ajaxExtFileName + WebSite.allUrl,
    //待处理
    myquestion_stuts2list_pageno:WebSite.webSiteContextURL + "index/myquestion_stuts2list_pageno" + WebSite.ajaxExtFileName + WebSite.allUrl,
    //已解决
    myquestion_stuts3list_pageno:WebSite.webSiteContextURL + "index/myquestion_stuts3list_pageno" + WebSite.ajaxExtFileName + WebSite.allUrl,

}

/**
 * 精华问题
 * @type {{url: string, essencesquestion_list: string, essencesquestion_template: string, essencesquestion_versiontemplate: string, search: string}}
 */
WebSite.EssenceQuestionPage = {
    url:WebSite.websitePageURL + "essenceQuestion.html"+WebSite.allUrl,
    essencesquestion_list           : WebSite.webSiteContextURL + "index/essencesquestion_list_pageno"+WebSite.ajaxExtFileName + WebSite.allUrl,
    essencesquestion_template       : WebSite.webSiteContextURL + "index/questionmodel_list" + WebSite.ajaxExtFileName + WebSite.allUrl,
    essencesquestion_versiontemplate: WebSite.webSiteContextURL + "index/questionvision_list" + WebSite.ajaxExtFileName + WebSite.allUrl,
    search                          : WebSite.webSiteContextURL + "index/essencesquestion_list_pageno" +WebSite.ajaxExtFileName + WebSite.allUrl,
}
/**
 * 等你来回答
 * @type {{url: string, allquestion_list: string, allQuestion_template: string, allQuestion_versiontemplate: string, search: string}}
 */
WebSite.AllQuestionPage = {
    url:WebSite.websitePageURL + "allQuestion.html"+WebSite.allUrl,
    allquestion_list           : WebSite.webSiteContextURL + "index/searchquestion_mv_list_pageno"+WebSite.ajaxExtFileName + WebSite.allUrl,
    allQuestion_template       : WebSite.webSiteContextURL + "index/questionmodel_list" + WebSite.ajaxExtFileName + WebSite.allUrl,
    allQuestion_versiontemplate: WebSite.webSiteContextURL + "index/questionvision_list" + WebSite.ajaxExtFileName + WebSite.allUrl,
    allquestion_type           : WebSite.webSiteContextURL + "index/questiontype_list" + WebSite.ajaxExtFileName + WebSite.allUrl,
    search                     : WebSite.webSiteContextURL + "index/searchquestion_mv_list_pageno" +WebSite.ajaxExtFileName + WebSite.allUrl,
}

WebSite.MyAnswerListPage = {
    url :WebSite.websitePageURL + "myAnswer.html"+WebSite.allUrl,

    /*精华问题*/
    essencequestion_list :WebSite.webSiteContextURL + "index/essencesquestion_list"+ WebSite.ajaxExtFileName + WebSite.allUrl,

    myanswer_list_pageno: WebSite.webSiteContextURL + "index/myanswer_list_pageno"+ WebSite.ajaxExtFileName + WebSite.allUrl,
    //已采纳
    myanswer_list_pageno_adopt1: WebSite.webSiteContextURL + "index/myanswer_list_pageno_adopt1" + WebSite.ajaxExtFileName + WebSite.allUrl,
    //未采纳
    myanswer_list_pageno_adopt0: WebSite.webSiteContextURL + "index/myanswer_list_pageno_adopt0" + WebSite.ajaxExtFileName + WebSite.allUrl,
    //待解决
    myanswer_list_pageno_status1: WebSite.webSiteContextURL + "index/myanswer_list_pageno_status1" + WebSite.ajaxExtFileName  + WebSite.allUrl,
}



JsAndCssUtil = {
    importCss :function(cssFilePath) {
        var product_ext_file_name = "";
        if (WebSite.enviromentType === "product") {
            product_ext_file_name = ".min";
        }
        document.write("<link rel=\"stylesheet\" href=\"" + WebSite.hostUrl + cssFilePath + product_ext_file_name + ".css\"/>");
    },

    importJs : function(jsFilePath) {
        var product_ext_file_name = "";
        if (WebSite.enviromentType === "product") {
            product_ext_file_name = ".min";
        }
        document.write("<script type='text/javascript' src='" + WebSite.hostUrl + jsFilePath + product_ext_file_name + ".js'></script>");
    }
}

var renderNavBar = function(){
    /*头部logo与我要提问的显示*/
    var Banner_html = '<div class="header" id="header_style">'
        +'<div class="am-container">'
        +'<div class="am-align-left hp-header-left-container float">'
        +'<p class="hp-header-left-title">'
        +'用友 · 在线运维 '
        +'<span class="hp-header-left-littleSize">'
        +'  您的疑惑，我们替你解答，我们的口号是：有什么不会的，尽管冲我来！'
        +'</span>'
        +'</p>'
        +'<p class="hp-english">'
        +'yonyou online · operation : you ask anything, we answer everything'
        +'</p>'
        +'</div>'
        +'<div class="am-align-right hp-header-right-container float">'
        +'<div class="float right-tip">'
        +'</div>'
        +'<div class="am-u-lg-3 am-u-md-6 am-u-sm-12 float">'
        +'<a href="'+WebSite.CommitPage.url+'">'
        +'<button class="am-btn am-btn-secondary hp-button-color">'
        +'我要提问'
        +'</button>'
        +'</a>'
        +'</div>'
        +'</div>'
        +'</div>'
        +'</div>';

    /*获取搜索条中的数据*/
    var keyword = getUrlParam("keyword");
    if(keyword == null){
        keyword = "";
    }else{
        keyword = decodeURI(getUrlParam("keyword"));
    }

    /**
     * 导航条
     * @type {string}
     */
    var nav_html = '<div class="nav">'
        + '<div class="am-topbar am-topbar-inverse">'
        + '<div class="am-container doc-nav-a">'
        + '<ul id="subnav" class="am-nav am-nav-pills am-topbar-nav doc-ul-location">'
        + '<li><a href="'+WebSite.IndexPage.url+'">首页</a></li>'
        + '<li><a href="'+WebSite.EssenceQuestionPage.url+'">精华问题</a></li>'
        + '<li><a href="'+WebSite.MyQuestionListPage.url+'">我的问题</a></li>'
        + '<li><a href="'+WebSite.AllQuestionPage.url+'">等你来回答</a></li>'
        + '<li class="doc-ul-hide">&nbsp;&nbsp;</li>'
        + '</ul>'
        + '<div class="am-input-group am-input-group-sm am-u-lg-4 am-u-md-6 am-u-sm-12" id="doc-search-show">'
        + '<span class="am-input-group-btn am-input-group-sm">'
        + '<input type="text" class="am-form-field " placeholder="搜索" id="kw" value="'+keyword+'">'
        + '<button class="am-btn am-btn-primary" type="button" id="searchButton">'
        + '<i class="am-icon-search fa-1x"></i>'
        + '</button>'
        + '</span>'
        + '</div>'
        + '</div>'
        + '</div>'
        + '</div>';

    var all_html = Banner_html + nav_html;

    document.write(all_html);
};








